package com.xueyi.aixihu.controller;

import com.xueyi.aixihu.controller.base.BaseController;
import com.xueyi.aixihu.entity.po.DtAuthGroup;
import com.xueyi.aixihu.entity.vo.DtAuthGroupTitleVo;
import com.xueyi.aixihu.entity.vo.LocalDtAuthGroupVo;
import com.xueyi.aixihu.reqeust.AddAuthGroupReq;
import com.xueyi.aixihu.reqeust.FindAllAuthGroupReq;
import com.xueyi.aixihu.response.FindAllAuthGroupResponse;
import com.xueyi.aixihu.response.base.BaseResponse;
import com.xueyi.aixihu.service.DtAuthGroupService;
import org.apache.ibatis.annotations.Options;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lvyi
 * @date : 2022/8/17
 * @Description : 角色表的controller类
 */
@RestController
public class DtAuthGroupController extends BaseController {

    @Autowired
    private DtAuthGroupService dtAuthGroupService;

    /**
     * 查询所有角色名
     *
     * @return 角色名
     */
//    @RequestMapping("/dtAuthGroup/findAllAuthGroupTitle")
//    public BaseResponse<List<DtAuthGroupTitleVo>> findAllAuthGroupTitle() {
//        return dtAuthGroupService.findAllAuthGroupTitle();
//    }


    /**
     * 查询出所有角色信息 以及关联其角色的条数
     *
     * @return
     */
    @RequestMapping("/dtAuthGroup/findAllAuthGroup")
    public FindAllAuthGroupResponse findAllAuthGroup(FindAllAuthGroupReq findAllAuthGroupReq) {
        return dtAuthGroupService.findAllAuthGroup(findAllAuthGroupReq);
    }

    /**
     * 编辑角色的名称
     *
     * @param id   角色id
     * @param name 名称
     */
    @RequestMapping("/dtAuthGroup/updateAuthName")
    public BaseResponse<Boolean> updateAuthName(Integer id, String name) {
        return dtAuthGroupService.updateAuthName(id, name);
    }

    /**
     * 修改角色的状态
     *
     * @param id     角色id
     * @param status 角色状态
     */
    @RequestMapping("/dtAuthGroup/updateAuthStatus")
    public BaseResponse<Boolean> updateAuthStatus(Integer id, Integer status) {
        return dtAuthGroupService.updateAuthStatus(id, status);
    }

    /**
     * 新增角色
     *
     * @param addAuthGroupReq
     */
    @RequestMapping("/dtAuthGroup/addAuthGroup")
    public BaseResponse<Boolean> addAuthGroup(AddAuthGroupReq addAuthGroupReq) {
        return dtAuthGroupService.addAuthGroup(addAuthGroupReq);
    }

    /**
     * 根据角色id查询其信息
     *
     * @param id
     * @return
     */
    @RequestMapping("/dtAuthGroup/findRoleById")
    public BaseResponse<DtAuthGroup> findRoleById(Integer id) {
        return dtAuthGroupService.findRoleById(id);
    }
}
